﻿/*********************************************************************
 版权所有: 版权所有(C) 2009 ,熙软研发部
 模块编号:  RoleAdd.aspx.cs
 作    者:范徐超
 编写日期:2009-09-09
 审    核:
 审核日期:
 描    述:规则添加页面
...........................................................................
如果模块有修改，则每次修改添加以下注释(以系统上线后为基准)：

 *********************************************************************/

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cisoft.Booking.Model;
using Cisoft.Booking.BLL;

public partial class Business_Booking_RuleAdd : WebUI.Page.BasePage
{
    private RuleMO ruleMO = new RuleMO();
    private RuleBO ruleBO = new RuleBO();

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    #region 按钮事件
    /// <summary>
    /// 新增事件
    /// </summary>
    protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        int i = 0;
        string strError = "";
        ruleMO = GetModel();
        try
        {
            i = ruleBO.Add(ruleMO);
        }
        catch(Exception ex)
        {
            strError = ex.Message;
        }
        if (i > 0)
        {
            PageRight("操作成功！", "RulesManage.aspx", "返回管理", "");
        }
        else
        {
            PageError(strError, Request.RawUrl);
        }
    }
    /// <summary>
    /// 返回事件
    /// </summary>
    protected void butrReset_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("RulesManage.aspx");
    }
    #endregion

    #region 填充规则实体类 private RuleMO GetModel()
    /// <summary>
    /// 填充规则实体类 
    /// </summary>
    private RuleMO GetModel()
    {
        string rulename = tb_RuleName.Text.Trim();
        string rulecode = tb_RuleCode.Text.Trim();
        string rulebreak = tb_RuleBreak.Text.Trim();
        string ruleend = tb_RuleEnd.Text.Trim();
        string rulesend = tb_RuleSend.Text;
        string rulereply = tb_RuleReply.Text;

        ruleMO.RuleID = ruleBO.GetMaxId();
        ruleMO.RuleName = rulename;
        ruleMO.RuleCode = rulecode;
        ruleMO.RuleBreakSymbol = rulebreak;
        ruleMO.RuleEndSymbol = ruleend;
        ruleMO.RuleOrderTemplate = rulesend;
        ruleMO.RuleReply = rulereply;

        ruleMO.RuelTable = "";

        return ruleMO;
    }
    #endregion
}
